<template>
    <div style="padding: 10px;">
        <el-form
                :model="formData"
                ref="queryForm"
                :inline="true"
                :rules="Rules"
                label-width="auto"
                @submit.native.prevent>
            
            <!-- elseuserName -->
            <el-form-item label="登录用户名"
                          desc="登录用户名"
                          prop="userName">
                <el-input
                        v-model.trim="formData.userName"
                        placeholder="登录用户名"
                        clearable
                        size="small"
                        style="width:120px;"
                />
            </el-form-item>
            
            
            <!-- elselastIp -->
            <!--      <el-form-item label="最近一次登录IP"
                  desc="最近一次登录IP"
                   prop="lastIp">
                                    <el-input
                                    v-model.trim="formData.lastIp"
                                    placeholder="最近一次登录IP"
                                    clearable
                                    size="small"
                                    style="width:120px;"
                                    />
                              </el-form-item>
-->
            
            
            <!--            &lt;!&ndash; elselastLoginTime &ndash;&gt;
                       <el-form-item label="最近登录时间"
                       desc="最近登录时间"
                        prop="lastLoginTime">
                                         <el-input
                                         v-model.trim="formData.lastLoginTime"
                                         placeholder="最近登录时间"
                                         clearable
                                         size="small"
                                         style="width:120px;"
                                         />
                                   </el-form-item>
-->
            
            
            <!--      &lt;!&ndash; elseip &ndash;&gt;
                 <el-form-item label="IP锁定可支持多个IP用逗号隔开"
                 desc="IP锁定可支持多个IP用逗号隔开"
                  prop="ip">
                                   <el-input
                                   v-model.trim="formData.ip"
                                   placeholder="IP锁定可支持多个IP用逗号隔开"
                                   clearable
                                   size="small"
                                   style="width:120px;"
                                   />
                             </el-form-item>
-->
            
            
            <!--
                         &lt;!&ndash; elseipState &ndash;&gt;
                        <el-form-item label="ip锁定状态[查询]0未锁定1己锁定"
                        desc="ip锁定状态[查询]0未锁定1己锁定"
                         prop="ipState">
                                          <el-input
                                          v-model.trim="formData.ipState"
                                          placeholder="ip锁定状态[查询]0未锁定1己锁定"
                                          clearable
                                          size="small"
                                          style="width:120px;"
                                          />
                                    </el-form-item>-->
            
            
            <!-- elseisAdmin -->
            <el-form-item label="是否为超级管理员"
                          desc="是否为超级管理员"
                          prop="isAdmin">
                <el-switch
                        v-model.trim="formData.isAdmin"
                        placeholder="是否为超级管理员[查询]"
                        clearable
                        size="small"
                        style="width:120px;margin-top: 8px;"
                        :active-value="5"
                        :inactive-value="1"
                >
                
                </el-switch>
            
            </el-form-item>
            
            
            <!-- elseonlieState -->
            <!--                    <el-form-item label="在线状态[数据字典=OnlieState]"
                                desc="在线状态[数据字典=OnlieState]"
                                 prop="onlieState">
                                                  <el-input
                                                  v-model.trim="formData.onlieState"
                                                  placeholder="在线状态[数据字典=OnlieState]"
                                                  clearable
                                                  size="small"
                                                  style="width:120px;"
                                                  />
                                            </el-form-item>
        
                     -->
            
            
            <el-form-item label="账号状态"
                          desc="账号状态[数据字典=AccountState]  1正常  5己停用"
                          prop="state">
                <dic-select
                        v-model="formData.state"
                        :code="dicInner.sys_account_state"
                        placeholder="账号状态[数据字典=AccountState]  1正常  5己停用"
                        clearable
                        size="small"
                        style="width:120px;"
                />
            </el-form-item>
            
            
            <!--     &lt;!&ndash; elseloginNum &ndash;&gt;
                <el-form-item label="累计登录次数"
                desc="累计登录次数"
                 prop="loginNum">
                                  <el-input
                                  v-model.trim="formData.loginNum"
                                  placeholder="累计登录次数"
                                  clearable
                                  size="small"
                                  style="width:120px;"
                                  />
                            </el-form-item>
-->
            
            
            <!-- elsepassWord -->
            <el-form-item label="登录密码"
                          desc="登录密码"
                          prop="passWord">
                <el-input
                        v-model.trim="formData.passWord"
                        placeholder="123456"
                        clearable
                        :disabled="true"
                        :type="formData.id?'password':'text'"
                        size="small"
                        style="width:120px;"
                />
            </el-form-item>
            
            
            <!--id -->
        
        
        </el-form>
    
    
    </div>


</template>

<script>
  import { getUrlParam } from '@/utils/index';
  import { alertWithPaylod } from '@/utils/alertUtil';
  import * as  api from '@/apis/sysAccount.api.js';
  import { default as FormDialog } from '@codegenarate/mydialogplus';
  import { fillData, validatePromise } from '@/utils/index';
  
  
  const Rules = {
    
    'serverNumber': [{ required: false, message: '服务器编号ID', trigger: 'blur' }],
    
    'lastEditTime': [{ required: false, message: '最近更新时间', trigger: 'blur' }],
    
    'editUserId': [{ required: false, message: '最近更新人ID', trigger: 'blur' }],
    
    'editUser': [{ required: false, message: '最近更新人', trigger: 'blur' }],
    
    'addTime': [{ required: false, message: '添加时间', trigger: 'blur' }],
    
    'addUserId': [{ required: false, message: '添加人ID', trigger: 'blur' }],
    
    'addUser': [{ required: false, message: '添加人', trigger: 'blur' }],
    
    'delState': [{ required: false, message: '有效状态[数据字典=del_state]', trigger: 'blur' }],
    
    'tenantId': [{ required: false, message: '租户ID', trigger: 'blur' }],
    
    'tenantType': [{ required: false, message: '租户类型', trigger: 'blur' }],
    
    'lastIp': [{ required: false, message: '最近一次登录IP', trigger: 'blur' }],
    
    'lastLoginTime': [{ required: false, message: '最近登录时间', trigger: 'blur' }],
    
    'ip': [{ required: false, message: 'IP锁定可支持多个IP用逗号隔开', trigger: 'blur' }],
    
    'ipState': [{ required: false, message: 'ip锁定状态[查询]0未锁定1己锁定', trigger: 'blur' }],
    
    'isAdmin': [{ required: false, message: '是否为超级管理员[查询]', trigger: 'blur' }],
    
    'onlieState': [{ required: false, message: '在线状态[数据字典=OnlieState]', trigger: 'blur' }],
    
    'state': [{ required: false, message: '账号状态[数据字典=AccountState]', trigger: 'blur' }],
    
    'loginNum': [{ required: false, message: '累计登录次数', trigger: 'blur' }],
    
    'passWord': [{ required: false, message: '登录密码', trigger: 'blur' }],
    
    'userName': [{ required: true, message: '登录用户名', trigger: 'blur' }],
    
    'id': [{ required: false, message: '主键ID', trigger: 'blur' }],
    
  };
  
  const dicInner = {
    
    '___sys_account_serverNumber': '服务器编号ID',
    'sys_account_serverNumber': 'sys_account_serverNumber',
    
    '___sys_account_lastEditTime': '最近更新时间',
    'sys_account_lastEditTime': 'sys_account_lastEditTime',
    
    '___sys_account_editUserId': '最近更新人ID',
    'sys_account_editUserId': 'sys_account_editUserId',
    
    '___sys_account_editUser': '最近更新人',
    'sys_account_editUser': 'sys_account_editUser',
    
    '___sys_account_addTime': '添加时间',
    'sys_account_addTime': 'sys_account_addTime',
    
    '___sys_account_addUserId': '添加人ID',
    'sys_account_addUserId': 'sys_account_addUserId',
    
    '___sys_account_addUser': '添加人',
    'sys_account_addUser': 'sys_account_addUser',
    
    '___sys_account_delState': '有效状态[数据字典=del_state] 1有效  5删除',
    'sys_account_delState': 'sys_account_delState',
    
    '___sys_account_tenantId': '租户ID',
    'sys_account_tenantId': 'sys_account_tenantId',
    
    '___sys_account_tenantType': '租户类型 1应用管理者2应用消息者',
    'sys_account_tenantType': 'sys_account_tenantType',
    
    '___sys_account_lastIp': '最近一次登录IP',
    'sys_account_lastIp': 'sys_account_lastIp',
    
    '___sys_account_lastLoginTime': '最近登录时间',
    'sys_account_lastLoginTime': 'sys_account_lastLoginTime',
    
    '___sys_account_ip': 'IP锁定可支持多个IP用逗号隔开',
    'sys_account_ip': 'sys_account_ip',
    
    '___sys_account_ipState': 'ip锁定状态[查询]0未锁定1己锁定',
    'sys_account_ipState': 'sys_account_ipState',
    
    '___sys_account_isAdmin': '是否为超级管理员[查询]',
    'sys_account_isAdmin': 'sys_account_isAdmin',
    
    '___sys_account_onlieState': '在线状态[数据字典=OnlieState]',
    'sys_account_onlieState': 'sys_account_onlieState',
    
    '___sys_account_state': '账号状态[数据字典=AccountState]  1正常  5己停用',
    'sys_account_state': 'sys_account_state',
    
    '___sys_account_loginNum': '累计登录次数',
    'sys_account_loginNum': 'sys_account_loginNum',
    
    '___sys_account_passWord': '登录密码',
    'sys_account_passWord': 'sys_account_passWord',
    
    '___sys_account_userName': '登录用户名',
    'sys_account_userName': 'sys_account_userName',
    
    '___sys_account_id': '主键ID',
    'sys_account_id': 'sys_account_id',
    
  };
  
  export default {
    name: 'sysAccountModify',
    data() {
      return {
        api: api,
        Rules,
        dicInner,
        formData: {
          
          'serverNumber': '',
          
          'lastEditTime': '',
          
          'editUserId': '',
          
          'editUser': '',
          
          'addTime': '',
          
          'addUserId': '',
          
          'addUser': '',
          
          'delState': '',
          
          'tenantId': '',
          
          'tenantType': '',
          
          'lastIp': '',
          
          'lastLoginTime': '',
          
          'ip': '',
          
          'ipState': '',
          
          'isAdmin': '',
          
          'onlieState': '',
          
          'state': '',
          
          'loginNum': '',
          
          'passWord': '',
          
          'userName': '',
          
          'id': '',
          
        },
        lists: [],
        selectRows: [],
        classId: '',
        classIdPath: '',
        className: '',
        loading: false,
        isFold: false,
        tableRowClassName({ row, rowIndex }) {
          if (row.rowType == 'total') {
            return 'total-row';
          }
          return '';
        },
      };
    },
    components: {
      svgIcon: () => import('@codegenarate/svg-icon'),
      dicSelect: () => import('@/components/dicselect.vue'),
      dicTag: () => import('@/components/DicSelect/dic-tag.vue'),
    },
    computed: {},
    watch: {},
    methods: {
      /**
       *  @params _data.
       * @desc 初始化
       */
      initByDialog(_data) {
        fillData(this.formData, _data);
        console.log('初始化数据', this.formData);
      },
      async submitByDialog(_data) {
        var isyes = await validatePromise.call(this, 'queryForm');
        if (!isyes) {
          return { success: false, message: '请检查必填项' };
        }
        var func = this.formData.id ? api.update : api.add;
        var result = await func(this.formData);
        alertWithPaylod(result);
        return result;
        
      },
      
    },
  };
</script>
